package com.ylbh.modules.shopping_orderform.controller;

import java.util.Arrays;
import java.util.Map;

import com.ylbh.common.utils.PageUtils;
import com.ylbh.common.utils.R;
import com.ylbh.modules.shopping_orderform.entity.ShoppingOrderformEntity;
import com.ylbh.modules.shopping_orderform.service.ShoppingOrderformService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ylbh.common.utils.PageUtils;
import com.ylbh.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-04-11 15:38:56
 */
@RestController
@RequestMapping("orderform/shoppingorderform")
public class ShoppingOrderformController {
    @Autowired
    private ShoppingOrderformService shoppingOrderformService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("orderform:shoppingorderform:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = shoppingOrderformService.orderlist(params);
//        PageUtils page = shoppingOrderformService.queryActivityGoodsList(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("orderform:shoppingorderform:info")
    public R info(@PathVariable("id") Long id){
		ShoppingOrderformEntity shoppingOrderform = shoppingOrderformService.getById(id);

        return R.ok().put("shoppingOrderform", shoppingOrderform);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("orderform:shoppingorderform:add")
    public R save(@RequestBody ShoppingOrderformEntity shoppingOrderform){
		shoppingOrderformService.save(shoppingOrderform);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("orderform:shoppingorderform:update")
    public R update(@RequestBody ShoppingOrderformEntity shoppingOrderform){
		shoppingOrderformService.updateById(shoppingOrderform);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("orderform:shoppingorderform:delete")
    public R delete(@RequestBody Long[] ids){
		shoppingOrderformService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
